const { Schema, model } = require('mongoose')
const { userModel } = require('./userModel')
const { insurancesModel } = require("./insurancesModel")

const ordersSchema = new Schema({
  delete: {
    type: Boolean,
    default: false
  },
  ordersPayState: {
    type: Number,
    default: 0
  },
  ordersState: {
    type: Number,
    default: 1
  },
  ordersTime: {
    type: Date,
    default: Date.now
  },
  ordersName: String,
  payPhone: {
    type: String,
    require: /^1\d{10}|\d{12}$/
  },
  insurancesId: {
    type: Schema.Types.ObjectId,
    ref: insurancesModel
  },
  usersId: {
    type: Schema.Types.ObjectId,
    ref: userModel
  },
  //待完善，需要链接到理赔时间
  ordersClaimsTime: {
    type: Date
  },
}, { versionKey: false })
module.exports.ordersModel = model("ordersModel", ordersSchema, "orders")
